package com.www.applyword.fragment;

import android.content.Intent;
import android.os.Bundle;
import android.view.View;

import androidx.annotation.Nullable;

import com.tencent.qcloud.tim.uikit.component.TitleBarLayout;
import com.tencent.qcloud.tim.uikit.modules.contact.ContactLayout;
import com.tencent.qcloud.tim.uikit.modules.contact.ContactListView;
import com.tencent.qcloud.tim.uikit.utils.TUIKitConstants;
import com.www.applyword.R;
import com.www.applyword.base.BaseFragment;
import com.www.applyword.ui.chat.BlackListActivity;
import com.www.applyword.ui.chat.FriendProfileActivity;
import com.www.applyword.ui.chat.GroupListActivity;
import com.www.applyword.ui.chat.NewFriendActivity;

/**
 * author : huang
 * date   : 2019/10/26 0026 14:09
 * version: 1.0
 */
public class BossFragment extends BaseFragment {
  //  @BindView(R.id.contact_layout)
    ContactLayout mContactLayout;

    @Override
    protected int getLayoutResource() {
        return R.layout.boss_fragment;
    }

    @Override
    public void onActivityCreated(@Nullable Bundle savedInstanceState) {
        super.onActivityCreated(savedInstanceState);
        mContactLayout =  rootView.findViewById(R.id.contact_layout);
        TitleBarLayout titleBarLayout = mContactLayout.findViewById(R.id.contact_titlebar);
        titleBarLayout.setVisibility(View.GONE);
        initView();
    }

    @Override
    public void onResume() {
        super.onResume();
     //   DemoLog.i(TAG, "onResume");
        refreshData();
    }

    private void refreshData() {
        // 通讯录面板的默认 UI 和交互初始化
       // mContactLayout.initDefault();
        mContactLayout.getContactListView().loadDataSource(ContactListView.DataSource.FRIEND_LIST);
    }

    private void initView() {
        mContactLayout.getContactListView().setOnItemClickListener((position, contact) -> {
                Intent intent = new Intent(getActivity(), FriendProfileActivity.class);
                intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
                intent.putExtra(TUIKitConstants.ProfileType.CONTENT, contact);
                getActivity().startActivity(intent);
        });
    }
}
